package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class jdbcdemo5
{
    public static void main(String[] args)
    {
        try(Connection con=DButil.getConnection();) {
            Statement sa=con.createStatement();
            String sql="SELECT ID,NAME,SALARY,TITLE FROM TEACHER";
            ResultSet re=sa.executeQuery(sql);
            while(re.next())
            {
                String id=re.getString("ID");
                String name=re.getString("NAME");
                String salary=re.getString("SALARY");
                String title=re.getString("TITLE");
                System.out.println(id+","+name+","+salary+","+title);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
